package com.woniu.p2p.behindServiceImpl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniu.p2p.behindService.ProjectBreifService;
import com.woniu.p2p.entity.*;
import com.woniu.p2p.mapper.*;
import com.woniu.p2p.vo.AllInvestVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class ProjectBreifServiceImpl implements ProjectBreifService {

    @Autowired
    InvestMapper investMapper;
    @Autowired
    InvestRepayMapper investRepayMapper;
    @Autowired
    InvestStafguardMapper investStafguardMapper;
    @Autowired
    InvestCompanyMapper investCompanyMapper;
    @Autowired
    InvestRiskMapper investRiskMapper;
    @Autowired
    InvestStatusMapper investStatusMapper;
    @Autowired
    InvestTypeMapper investTypeMapper;

    @Override
    public PageInfo<AllInvestVo> findAllInvest(Integer start, Integer num, String investstatus, Date predate, Date nextdate, String investkeyword) {
        PageHelper.startPage(start,num);
        List<AllInvestVo> list = investMapper.findAllInvest(investstatus, predate, nextdate, investkeyword);
        PageInfo<AllInvestVo> pageInfo=new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public List<AllInvestVo> findAllInvest2(int[] id) {
        List<AllInvestVo> list = investMapper.findAllInvestByIdes(id);
        return list;
    }

    @Override
    public int deleteInvestById(Integer id) {
        int i = investMapper.deleteByPrimaryKey(id);
        return 1;
    }

    @Override
    public List<InvestRepay> findAllInvestRepay() {
        return investRepayMapper.selectAll();
    }

    @Override
    public List<InvestStafguard> findAllStaf() {
        return investStafguardMapper.selectAll();
    }

    @Override
    public List<InvestCompany> findAllCompany() {
        return investCompanyMapper.selectAll();
    }

    @Override
    public List<InvestRisk> findAllRisk() {
        return investRiskMapper.selectAll();
    }

    @Override
    public List<InvestStatus> findAllStatus() {
        return investStatusMapper.selectAll();
    }

    @Override
    public List<InvestType> findAllType() {
        return investTypeMapper.selectAll();
    }

    @Override
    public int insertInvest(Invest invest) {
        return investMapper.insert(invest);
    }

    @Override
    public InvestCompany findAllCompanyDetails(Integer id) {
        return investCompanyMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<AllInvestVo> findall() {
        return investMapper.findAll();
    }
}
